{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 房价数据预测——线性回归分析\n",
    "数据说明： Capital Bikeshare （美国Washington, D.C.的一个共享单车公司）提供的共享单车数据。数据包含每天的日期、天气等信息，需要预测每天的共享单车骑行量。"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "1、导入必要的工具包"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np  # 矩阵操作\n",
    "import pandas as pd # SQL数据处理\n",
    "\n",
    "from sklearn.metrics import r2_score  #评价回归预测模型的性能\n",
    "\n",
    "import matplotlib.pyplot as plt   #画图\n",
    "import seaborn as sns\n",
    "\n",
    "# 图形出现在Notebook里而不是新窗口\n",
    "%matplotlib inline"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "2、数据探索"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "2.1 读取数据"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Id</th>\n",
       "      <th>MSSubClass</th>\n",
       "      <th>MSZoning</th>\n",
       "      <th>LotFrontage</th>\n",
       "      <th>LotArea</th>\n",
       "      <th>Street</th>\n",
       "      <th>Alley</th>\n",
       "      <th>LotShape</th>\n",
       "      <th>LandContour</th>\n",
       "      <th>Utilities</th>\n",
       "      <th>...</th>\n",
       "      <th>PoolArea</th>\n",
       "      <th>PoolQC</th>\n",
       "      <th>Fence</th>\n",
       "      <th>MiscFeature</th>\n",
       "      <th>MiscVal</th>\n",
       "      <th>MoSold</th>\n",
       "      <th>YrSold</th>\n",
       "      <th>SaleType</th>\n",
       "      <th>SaleCondition</th>\n",
       "      <th>SalePrice</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>60</td>\n",
       "      <td>RL</td>\n",
       "      <td>65.0</td>\n",
       "      <td>8450</td>\n",
       "      <td>Pave</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Reg</td>\n",
       "      <td>Lvl</td>\n",
       "      <td>AllPub</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "      <td>2008</td>\n",
       "      <td>WD</td>\n",
       "      <td>Normal</td>\n",
       "      <td>208500</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2</td>\n",
       "      <td>20</td>\n",
       "      <td>RL</td>\n",
       "      <td>80.0</td>\n",
       "      <td>9600</td>\n",
       "      <td>Pave</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Reg</td>\n",
       "      <td>Lvl</td>\n",
       "      <td>AllPub</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0</td>\n",
       "      <td>5</td>\n",
       "      <td>2007</td>\n",
       "      <td>WD</td>\n",
       "      <td>Normal</td>\n",
       "      <td>181500</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>3</td>\n",
       "      <td>60</td>\n",
       "      <td>RL</td>\n",
       "      <td>68.0</td>\n",
       "      <td>11250</td>\n",
       "      <td>Pave</td>\n",
       "      <td>NaN</td>\n",
       "      <td>IR1</td>\n",
       "      <td>Lvl</td>\n",
       "      <td>AllPub</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0</td>\n",
       "      <td>9</td>\n",
       "      <td>2008</td>\n",
       "      <td>WD</td>\n",
       "      <td>Normal</td>\n",
       "      <td>223500</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>4</td>\n",
       "      <td>70</td>\n",
       "      <td>RL</td>\n",
       "      <td>60.0</td>\n",
       "      <td>9550</td>\n",
       "      <td>Pave</td>\n",
       "      <td>NaN</td>\n",
       "      <td>IR1</td>\n",
       "      <td>Lvl</td>\n",
       "      <td>AllPub</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "      <td>2006</td>\n",
       "      <td>WD</td>\n",
       "      <td>Abnorml</td>\n",
       "      <td>140000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>5</td>\n",
       "      <td>60</td>\n",
       "      <td>RL</td>\n",
       "      <td>84.0</td>\n",
       "      <td>14260</td>\n",
       "      <td>Pave</td>\n",
       "      <td>NaN</td>\n",
       "      <td>IR1</td>\n",
       "      <td>Lvl</td>\n",
       "      <td>AllPub</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0</td>\n",
       "      <td>12</td>\n",
       "      <td>2008</td>\n",
       "      <td>WD</td>\n",
       "      <td>Normal</td>\n",
       "      <td>250000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>5 rows × 81 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "   Id  MSSubClass MSZoning  LotFrontage  LotArea Street Alley LotShape  \\\n",
       "0   1          60       RL         65.0     8450   Pave   NaN      Reg   \n",
       "1   2          20       RL         80.0     9600   Pave   NaN      Reg   \n",
       "2   3          60       RL         68.0    11250   Pave   NaN      IR1   \n",
       "3   4          70       RL         60.0     9550   Pave   NaN      IR1   \n",
       "4   5          60       RL         84.0    14260   Pave   NaN      IR1   \n",
       "\n",
       "  LandContour Utilities    ...     PoolArea PoolQC Fence MiscFeature MiscVal  \\\n",
       "0         Lvl    AllPub    ...            0    NaN   NaN         NaN       0   \n",
       "1         Lvl    AllPub    ...            0    NaN   NaN         NaN       0   \n",
       "2         Lvl    AllPub    ...            0    NaN   NaN         NaN       0   \n",
       "3         Lvl    AllPub    ...            0    NaN   NaN         NaN       0   \n",
       "4         Lvl    AllPub    ...            0    NaN   NaN         NaN       0   \n",
       "\n",
       "  MoSold YrSold  SaleType  SaleCondition  SalePrice  \n",
       "0      2   2008        WD         Normal     208500  \n",
       "1      5   2007        WD         Normal     181500  \n",
       "2      9   2008        WD         Normal     223500  \n",
       "3      2   2006        WD        Abnorml     140000  \n",
       "4     12   2008        WD         Normal     250000  \n",
       "\n",
       "[5 rows x 81 columns]"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# path to where the data lies\n",
    "#dpath = './data/'\n",
    "train_data = pd.read_csv(\"Ames_House_train.csv\")\n",
    "\n",
    "#通过观察前5行，了解数据每列（特征）的概况\n",
    "train_data.head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "2.2 数据基本信息\n",
    "样本数目、特征维数\n",
    "每个特征的类型、空值样本的数目、数据类型"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(1460, 81)"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "train_data.shape"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "2.3 数据探索\n",
    "请见另一个文件：1week_0_Explore.pynb\n",
    "\n",
    "对数据的探索有助于我们在第三步中根据数据的特点选择合适的模型类型"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "2.4 数据准备"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Id</th>\n",
       "      <th>MSSubClass</th>\n",
       "      <th>MSZoning</th>\n",
       "      <th>LotFrontage</th>\n",
       "      <th>LotArea</th>\n",
       "      <th>Street</th>\n",
       "      <th>Alley</th>\n",
       "      <th>LotShape</th>\n",
       "      <th>LandContour</th>\n",
       "      <th>Utilities</th>\n",
       "      <th>...</th>\n",
       "      <th>PoolArea</th>\n",
       "      <th>PoolQC</th>\n",
       "      <th>Fence</th>\n",
       "      <th>MiscFeature</th>\n",
       "      <th>MiscVal</th>\n",
       "      <th>MoSold</th>\n",
       "      <th>YrSold</th>\n",
       "      <th>SaleType</th>\n",
       "      <th>SaleCondition</th>\n",
       "      <th>SalePrice</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>60</td>\n",
       "      <td>RL</td>\n",
       "      <td>65.0</td>\n",
       "      <td>8450</td>\n",
       "      <td>Pave</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Reg</td>\n",
       "      <td>Lvl</td>\n",
       "      <td>AllPub</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "      <td>2008</td>\n",
       "      <td>WD</td>\n",
       "      <td>Normal</td>\n",
       "      <td>208500</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2</td>\n",
       "      <td>20</td>\n",
       "      <td>RL</td>\n",
       "      <td>80.0</td>\n",
       "      <td>9600</td>\n",
       "      <td>Pave</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Reg</td>\n",
       "      <td>Lvl</td>\n",
       "      <td>AllPub</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0</td>\n",
       "      <td>5</td>\n",
       "      <td>2007</td>\n",
       "      <td>WD</td>\n",
       "      <td>Normal</td>\n",
       "      <td>181500</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>3</td>\n",
       "      <td>60</td>\n",
       "      <td>RL</td>\n",
       "      <td>68.0</td>\n",
       "      <td>11250</td>\n",
       "      <td>Pave</td>\n",
       "      <td>NaN</td>\n",
       "      <td>IR1</td>\n",
       "      <td>Lvl</td>\n",
       "      <td>AllPub</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0</td>\n",
       "      <td>9</td>\n",
       "      <td>2008</td>\n",
       "      <td>WD</td>\n",
       "      <td>Normal</td>\n",
       "      <td>223500</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>4</td>\n",
       "      <td>70</td>\n",
       "      <td>RL</td>\n",
       "      <td>60.0</td>\n",
       "      <td>9550</td>\n",
       "      <td>Pave</td>\n",
       "      <td>NaN</td>\n",
       "      <td>IR1</td>\n",
       "      <td>Lvl</td>\n",
       "      <td>AllPub</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "      <td>2006</td>\n",
       "      <td>WD</td>\n",
       "      <td>Abnorml</td>\n",
       "      <td>140000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>5</td>\n",
       "      <td>60</td>\n",
       "      <td>RL</td>\n",
       "      <td>84.0</td>\n",
       "      <td>14260</td>\n",
       "      <td>Pave</td>\n",
       "      <td>NaN</td>\n",
       "      <td>IR1</td>\n",
       "      <td>Lvl</td>\n",
       "      <td>AllPub</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0</td>\n",
       "      <td>12</td>\n",
       "      <td>2008</td>\n",
       "      <td>WD</td>\n",
       "      <td>Normal</td>\n",
       "      <td>250000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>5 rows × 81 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "   Id  MSSubClass MSZoning  LotFrontage  LotArea Street Alley LotShape  \\\n",
       "0   1          60       RL         65.0     8450   Pave   NaN      Reg   \n",
       "1   2          20       RL         80.0     9600   Pave   NaN      Reg   \n",
       "2   3          60       RL         68.0    11250   Pave   NaN      IR1   \n",
       "3   4          70       RL         60.0     9550   Pave   NaN      IR1   \n",
       "4   5          60       RL         84.0    14260   Pave   NaN      IR1   \n",
       "\n",
       "  LandContour Utilities    ...     PoolArea PoolQC Fence MiscFeature MiscVal  \\\n",
       "0         Lvl    AllPub    ...            0    NaN   NaN         NaN       0   \n",
       "1         Lvl    AllPub    ...            0    NaN   NaN         NaN       0   \n",
       "2         Lvl    AllPub    ...            0    NaN   NaN         NaN       0   \n",
       "3         Lvl    AllPub    ...            0    NaN   NaN         NaN       0   \n",
       "4         Lvl    AllPub    ...            0    NaN   NaN         NaN       0   \n",
       "\n",
       "  MoSold YrSold  SaleType  SaleCondition  SalePrice  \n",
       "0      2   2008        WD         Normal     208500  \n",
       "1      5   2007        WD         Normal     181500  \n",
       "2      9   2008        WD         Normal     223500  \n",
       "3      2   2006        WD        Abnorml     140000  \n",
       "4     12   2008        WD         Normal     250000  \n",
       "\n",
       "[5 rows x 81 columns]"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "train_data.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Index(['Id', 'LotFrontage', 'LotArea', 'OverallQual', 'YearBuilt',\n",
      "       'YearRemodAdd', 'MasVnrArea', 'BsmtFinSF1', 'BsmtFinSF2', 'BsmtUnfSF',\n",
      "       'TotalBsmtSF', '1stFlrSF', '2ndFlrSF', 'GrLivArea', 'BsmtFullBath',\n",
      "       'FullBath', 'HalfBath', 'BedroomAbvGr', 'KitchenAbvGr', 'TotRmsAbvGrd',\n",
      "       'Fireplaces', 'GarageYrBlt', 'GarageCars', 'GarageArea', 'WoodDeckSF',\n",
      "       'OpenPorchSF'],\n",
      "      dtype='object')\n"
     ]
    }
   ],
   "source": [
    "# 从原始数据中分离输入特征x和输出y\n",
    "y = train_data['SalePrice'].values\n",
    "\n",
    "#去掉非数字数据\n",
    "train_dataRemove = train_data.drop('MSSubClass',axis = 1)\n",
    "train_dataRemove = train_dataRemove.drop('MSZoning',axis = 1)\n",
    "train_dataRemove = train_dataRemove.drop('Street',axis = 1)\n",
    "train_dataRemove = train_dataRemove.drop('Alley',axis = 1)\n",
    "train_dataRemove = train_dataRemove.drop('LotShape',axis = 1)\n",
    "train_dataRemove = train_dataRemove.drop('LandContour',axis = 1)\n",
    "train_dataRemove = train_dataRemove.drop('Utilities',axis = 1)\n",
    "train_dataRemove = train_dataRemove.drop('LotConfig',axis = 1)\n",
    "train_dataRemove = train_dataRemove.drop('LandSlope',axis = 1)\n",
    "train_dataRemove = train_dataRemove.drop('Neighborhood',axis = 1)\n",
    "train_dataRemove = train_dataRemove.drop('Condition1',axis = 1)\n",
    "train_dataRemove = train_dataRemove.drop('Condition2',axis = 1)\n",
    "train_dataRemove = train_dataRemove.drop('BldgType',axis = 1)\n",
    "train_dataRemove = train_dataRemove.drop('HouseStyle',axis = 1)\n",
    "train_dataRemove = train_dataRemove.drop('RoofStyle',axis = 1)\n",
    "train_dataRemove = train_dataRemove.drop('RoofMatl',axis = 1)\n",
    "train_dataRemove = train_dataRemove.drop('Exterior1st',axis = 1)\n",
    "train_dataRemove = train_dataRemove.drop('Exterior2nd',axis = 1)\n",
    "train_dataRemove = train_dataRemove.drop('MasVnrType',axis = 1)\n",
    "train_dataRemove = train_dataRemove.drop('ExterQual',axis = 1)\n",
    "train_dataRemove = train_dataRemove.drop('ExterCond',axis = 1)\n",
    "train_dataRemove = train_dataRemove.drop('Foundation',axis = 1)\n",
    "train_dataRemove = train_dataRemove.drop('BsmtFinType1',axis = 1)\n",
    "train_dataRemove = train_dataRemove.drop('BsmtFinType2',axis = 1)\n",
    "train_dataRemove = train_dataRemove.drop('BsmtQual',axis = 1)\n",
    "train_dataRemove = train_dataRemove.drop('BsmtCond',axis = 1)\n",
    "train_dataRemove = train_dataRemove.drop('BsmtExposure',axis = 1)\n",
    "train_dataRemove = train_dataRemove.drop('Heating',axis = 1)\n",
    "train_dataRemove = train_dataRemove.drop('HeatingQC',axis = 1)\n",
    "train_dataRemove = train_dataRemove.drop('CentralAir',axis = 1)\n",
    "train_dataRemove = train_dataRemove.drop('Electrical',axis = 1)\n",
    "train_dataRemove = train_dataRemove.drop('KitchenQual',axis = 1)\n",
    "train_dataRemove = train_dataRemove.drop('Functional',axis = 1)\n",
    "train_dataRemove = train_dataRemove.drop('FireplaceQu',axis = 1)\n",
    "train_dataRemove = train_dataRemove.drop('GarageType',axis = 1)\n",
    "train_dataRemove = train_dataRemove.drop('GarageFinish',axis = 1)\n",
    "train_dataRemove = train_dataRemove.drop('GarageQual',axis = 1)\n",
    "train_dataRemove = train_dataRemove.drop('GarageCond',axis = 1)\n",
    "train_dataRemove = train_dataRemove.drop('PavedDrive',axis = 1)\n",
    "train_dataRemove = train_dataRemove.drop('PoolQC',axis = 1)\n",
    "train_dataRemove = train_dataRemove.drop('Fence',axis = 1)\n",
    "train_dataRemove = train_dataRemove.drop('MiscFeature',axis = 1)\n",
    "train_dataRemove = train_dataRemove.drop('SaleType',axis = 1)\n",
    "train_dataRemove = train_dataRemove.drop('SaleCondition',axis = 1)\n",
    "\n",
    "#低关联性数据\n",
    "train_dataRemove = train_dataRemove.drop('OverallCond',axis = 1)\n",
    "train_dataRemove = train_dataRemove.drop('LowQualFinSF',axis = 1)\n",
    "train_dataRemove = train_dataRemove.drop('BsmtHalfBath',axis = 1)\n",
    "train_dataRemove = train_dataRemove.drop('EnclosedPorch',axis = 1)\n",
    "train_dataRemove = train_dataRemove.drop('3SsnPorch',axis = 1)\n",
    "train_dataRemove = train_dataRemove.drop('ScreenPorch',axis = 1)\n",
    "train_dataRemove = train_dataRemove.drop('PoolArea',axis = 1)\n",
    "train_dataRemove = train_dataRemove.drop('MiscVal',axis = 1)\n",
    "train_dataRemove = train_dataRemove.drop('MoSold',axis = 1)\n",
    "train_dataRemove = train_dataRemove.drop('YrSold',axis = 1)\n",
    "\n",
    "X = train_dataRemove.drop('SalePrice',axis = 1)\n",
    "\n",
    "#去掉存在空值的数据\n",
    "X = X.fillna(0.0)\n",
    "\n",
    "X.isnull().sum()\n",
    "\n",
    "#用于后续显示权重系数对应的特征\n",
    "columns = X.columns\n",
    "print(columns)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(1168, 26)"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#将数据分割训练数据与测试数据\n",
    "from sklearn.model_selection import train_test_split\n",
    "\n",
    "# 随机采样20%的数据构建测试样本，其余作为训练样本\n",
    "X_train, X_test, y_train, y_test = train_test_split(X, y, random_state=33, test_size=0.2)\n",
    "X_train.shape"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "2.5 数据预处理／特征工程\n",
    "特征工程是实际任务中特别重要的环节。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "C:\\Users\\YuGo\\Anaconda3\\lib\\site-packages\\sklearn\\utils\\validation.py:475: DataConversionWarning: Data with input dtype int64 was converted to float64 by StandardScaler.\n",
      "  warnings.warn(msg, DataConversionWarning)\n",
      "C:\\Users\\YuGo\\Anaconda3\\lib\\site-packages\\sklearn\\utils\\validation.py:475: DataConversionWarning: Data with input dtype int64 was converted to float64 by StandardScaler.\n",
      "  warnings.warn(msg, DataConversionWarning)\n",
      "C:\\Users\\YuGo\\Anaconda3\\lib\\site-packages\\sklearn\\utils\\validation.py:475: DataConversionWarning: Data with input dtype int64 was converted to float64 by StandardScaler.\n",
      "  warnings.warn(msg, DataConversionWarning)\n"
     ]
    }
   ],
   "source": [
    "# 数据标准化\n",
    "from sklearn.preprocessing import StandardScaler\n",
    "\n",
    "ss_X = StandardScaler()\n",
    "ss_y = StandardScaler()\n",
    "\n",
    "# 分别对训练和测试数据的特征以及目标值进行标准化处理\n",
    "X_train = ss_X.fit_transform(X_train)\n",
    "X_test = ss_X.transform(X_test)\n",
    "\n",
    "#对y做标准化不是必须\n",
    "#对y标准化的好处是不同问题的w差异不太大，同时正则参数的范围也有限\n",
    "y_train = ss_y.fit_transform(y_train.reshape(-1, 1))\n",
    "y_test = ss_y.transform(y_test.reshape(-1, 1))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "3、确定模型类型"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "3.1 尝试缺省参数的线性回归"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>columns</th>\n",
       "      <th>coef</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>2ndFlrSF</td>\n",
       "      <td>[0.2798480119217816]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>OverallQual</td>\n",
       "      <td>[0.26640865950351794]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>1stFlrSF</td>\n",
       "      <td>[0.2656173997572214]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>BsmtFinSF1</td>\n",
       "      <td>[0.10989253674651933]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>19</th>\n",
       "      <td>TotRmsAbvGrd</td>\n",
       "      <td>[0.10596469504353777]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>TotalBsmtSF</td>\n",
       "      <td>[0.10109684424132556]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>YearBuilt</td>\n",
       "      <td>[0.08344586707585637]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>YearRemodAdd</td>\n",
       "      <td>[0.07210770120005856]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>22</th>\n",
       "      <td>GarageCars</td>\n",
       "      <td>[0.07167564232808438]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>LotArea</td>\n",
       "      <td>[0.06549398788305008]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>23</th>\n",
       "      <td>GarageArea</td>\n",
       "      <td>[0.056587176144907346]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>MasVnrArea</td>\n",
       "      <td>[0.05018458602582234]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>LotFrontage</td>\n",
       "      <td>[0.039225534711106416]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20</th>\n",
       "      <td>Fireplaces</td>\n",
       "      <td>[0.03384965167255298]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>24</th>\n",
       "      <td>WoodDeckSF</td>\n",
       "      <td>[0.03317058510140644]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>Id</td>\n",
       "      <td>[0.007196596768281257]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25</th>\n",
       "      <td>OpenPorchSF</td>\n",
       "      <td>[0.00450082969436748]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>GrLivArea</td>\n",
       "      <td>[0.0019755310982400302]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>BsmtFinSF2</td>\n",
       "      <td>[-0.0011780504047946361]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16</th>\n",
       "      <td>HalfBath</td>\n",
       "      <td>[-0.003262494200630012]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>BsmtFullBath</td>\n",
       "      <td>[-0.004066592459833486]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>BsmtUnfSF</td>\n",
       "      <td>[-0.010493950450894874]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>FullBath</td>\n",
       "      <td>[-0.01601733078785253]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>21</th>\n",
       "      <td>GarageYrBlt</td>\n",
       "      <td>[-0.06683325230380059]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18</th>\n",
       "      <td>KitchenAbvGr</td>\n",
       "      <td>[-0.07995924897132729]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17</th>\n",
       "      <td>BedroomAbvGr</td>\n",
       "      <td>[-0.09459883857147754]</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "         columns                      coef\n",
       "12      2ndFlrSF      [0.2798480119217816]\n",
       "3    OverallQual     [0.26640865950351794]\n",
       "11      1stFlrSF      [0.2656173997572214]\n",
       "7     BsmtFinSF1     [0.10989253674651933]\n",
       "19  TotRmsAbvGrd     [0.10596469504353777]\n",
       "10   TotalBsmtSF     [0.10109684424132556]\n",
       "4      YearBuilt     [0.08344586707585637]\n",
       "5   YearRemodAdd     [0.07210770120005856]\n",
       "22    GarageCars     [0.07167564232808438]\n",
       "2        LotArea     [0.06549398788305008]\n",
       "23    GarageArea    [0.056587176144907346]\n",
       "6     MasVnrArea     [0.05018458602582234]\n",
       "1    LotFrontage    [0.039225534711106416]\n",
       "20    Fireplaces     [0.03384965167255298]\n",
       "24    WoodDeckSF     [0.03317058510140644]\n",
       "0             Id    [0.007196596768281257]\n",
       "25   OpenPorchSF     [0.00450082969436748]\n",
       "13     GrLivArea   [0.0019755310982400302]\n",
       "8     BsmtFinSF2  [-0.0011780504047946361]\n",
       "16      HalfBath   [-0.003262494200630012]\n",
       "14  BsmtFullBath   [-0.004066592459833486]\n",
       "9      BsmtUnfSF   [-0.010493950450894874]\n",
       "15      FullBath    [-0.01601733078785253]\n",
       "21   GarageYrBlt    [-0.06683325230380059]\n",
       "18  KitchenAbvGr    [-0.07995924897132729]\n",
       "17  BedroomAbvGr    [-0.09459883857147754]"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 线性回归\n",
    "#class sklearn.linear_model.LinearRegression(fit_intercept=True, normalize=False, copy_X=True, n_jobs=1)\n",
    "from sklearn.linear_model import LinearRegression\n",
    "\n",
    "# 使用默认配置初始化\n",
    "lr = LinearRegression()\n",
    "\n",
    "# 训练模型参数\n",
    "lr.fit(X_train, y_train)\n",
    "\n",
    "# 预测\n",
    "y_test_pred_lr = lr.predict(X_test)\n",
    "y_train_pred_lr = lr.predict(X_train)\n",
    "\n",
    "\n",
    "# 看看各特征的权重系数，系数的绝对值大小可视为该特征的重要性\n",
    "fs = pd.DataFrame({\"columns\":list(columns), \"coef\":list((lr.coef_.T))})\n",
    "fs.sort_values(by=['coef'],ascending=False)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "3.1.1 模型评价"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The r2 score of LinearRegression on test is      0.652\n",
      "The r2 score of LinearRegression on train is      0.831\n"
     ]
    }
   ],
   "source": [
    "# 使用r2_score评价模型在测试集和训练集上的性能，并输出评估结果\n",
    "#测试集\n",
    "print (\"The r2 score of LinearRegression on test is %10.3f\" % r2_score(y_test, y_test_pred_lr))\n",
    "#训练集\n",
    "print (\"The r2 score of LinearRegression on train is %10.3f\" % r2_score(y_train, y_train_pred_lr))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KG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ZOOOEEbrjhtVm3R48eDcCaNWuYM2cOBxxwAPvuuy833XTTJrWtXLmSgw8+mObmZvbZZx9+8Ytf9Gifbr/9dg4//HAAWltbOfHEE5k9eza77bbb60L9mmuuYcaMGTQ3N3PqqaduCOTTTjuNlpYW9t577w3vAdSm/j7vvPN497vfzQ9/+MMe1dJTHjaXJPXIunXrWLBgASeddBIAt9xyCw8//DD33HMPmckRRxzBwoULaW9vZ5ddduGnP/0pAM8+++zrtrNy5UrOPfdcFi9ezJgxY3jve9/L9OmbXBf9OqNGjeLGG29kxx135KmnnmLmzJkcccQRr7vw6/vf/z6HHHII55xzDuvWrePFF1/s034++OCD3HbbbTz//PO87W1v47TTTmP58uVcf/313HnnnTQ1NfHpT3+aa6+9luOOO47zzz+fcePGsW7dOubMmcPSpUvZb7/9NtR9xx139KmOzTG8JUmb9ac//Ynm5mYeffRR3vGOd/CBD3wAqIX3LbfcsiF416xZw8MPP8xBBx3E5z73Ob7whS9w+OGHc9BBB71ue3fffTezZ8+mY3bNo446it/+9rebrSEzOfvss1m4cCHbbLMNK1asYNWqVbz5zW/e0OfAAw/kxBNP5NVXX+XII4+kubm5T/t72GGHMXLkSEaOHMmECRNYtWoVCxYsYPHixRx44IEb3pMJEyYAMH/+fObNm8fatWtZuXIlDzzwwIbwPuqoo/pUQ3c8bC5J2qyOc96PPfYYr7zyyoZz3pnJWWedxZIlS1iyZAnLly/npJNOYo899mDx4sXsu+++nHXWWZx33nmbbLOrP5XadtttWb9+/Ybtv/LKKwBce+21tLe3s3jxYpYsWcLOO++8yaxzBx98MAsXLmTSpEkce+yxXH311X3a35EjR254PGLECNauXUtmcvzxx2/Y14ceeojW1lYeeeQRLrzwQhYsWMDSpUs57LDDXlfX9ttv36cauuPIW1Ixenql9UBfka2aMWPGcMkllzB37lxOO+00DjnkEL70pS9xzDHHMHr0aFasWEFTUxNr165l3LhxfPKTn2T06NFceeWVr9vOO9/5Ts4880xWr17NjjvuyA9/+EP2339/oHaeePHixXz84x/nppt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vomI5cBIYHXVdFdm/mUDS+qziPgo8I/AeOAZYElmHtLYqnqu+nPQ/8Vr0zGf3+CS+iwifgDMpvbVk6uAczPz8oYW1UcR8W7gF8BvqP2fBzi7xL8Aioj9gKuo/RvbBpifmec1rJ6tMbwlSdqabZWHzSVJ2poZ3pIkFcbwliSpMIa3JEmFMbwlSSqM4S1JUmEMb0mSCvP/AbeCKMgL4UHzAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 504x360 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "#在训练集上观察预测残差的分布，看是否符合模型假设：噪声为0均值的高斯噪声\n",
    "f, ax = plt.subplots(figsize=(7, 5)) \n",
    "f.tight_layout() \n",
    "ax.hist(y_train - y_train_pred_lr,bins=40, label='Residuals Linear', color='b', alpha=.5); \n",
    "ax.set_title(\"Histogram of Residuals\") \n",
    "ax.legend(loc='best');"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAARgAAADQCAYAAADcQn7hAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMi4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvhp/UCwAAHg5JREFUeJzt3XmUVPWVwPHv7eoCqlFokC00IC6IQVFRRAayKGowKoorxugZ44lGJzGQKK4ZxZg5EjFKnHCMjE5GxYkracV9wbghE8EGEVdEjTSyCW0LFNBdfeePqoKiupZXVe/1q+V+zuFAVb16dVupy2+9P1FVjDHGC1V+B2CMKV+WYIwxnrEEY4zxjCUYY4xnLMEYYzxjCcYY4xlLMMYYz1iCMcZ4xhKMMcYz1X4HkItevXrp4MGD/Q7DmIq3ePHiDaraO9t1JZVgBg8ezKJFi/wOw5iKJyKfO7nOukjGGM9YgjHGeMYSjDHGM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Y1wRG+DdJCJDRKQKOC3h5ReBn8cfiMhhKW7xPHBprAwoSV2kVL4B9iwsauM1SzDGTVcBzxKd1l6V8PzPgbGxQdr3gItSvPcuYA3wjogsBc7O8lmPA2fHBn9tkLdI2W5qY4xnrAVjjPGMJRhjjGcswRhjPGMJxhjjGUswxhjPWIIxxnjGEowxxjP/D2eS9FfU7TclAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 288x216 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "#还可以观察预测值与真值的散点图\n",
    "plt.figure(figsize=(4, 3))\n",
    "plt.scatter(y_train, y_train_pred_lr)\n",
    "plt.plot([-3, 3], [-3, 3], '--k')   #数据已经标准化，3倍标准差即可\n",
    "plt.axis('tight')\n",
    "plt.xlabel('True cnt')\n",
    "plt.ylabel('Predicted cnt')\n",
    "plt.tight_layout()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The r2 score of RidgeCV on test is 0.665817\n",
      "The r2 score of RidgeCV on train is 0.829363\n"
     ]
    }
   ],
   "source": [
    "#岭回归／L2正则\n",
    "#class sklearn.linear_model.RidgeCV(alphas=(0.1, 1.0, 10.0), fit_intercept=True, \n",
    "#                                  normalize=False, scoring=None, cv=None, gcv_mode=None, \n",
    "#                                  store_cv_values=False)\n",
    "from sklearn.linear_model import  RidgeCV\n",
    "\n",
    "#设置超参数（正则参数）范围\n",
    "alphas = [ 0.01, 0.1, 1, 10,100]\n",
    "#n_alphas = 20\n",
    "#alphas = np.logspace(-5,2,n_alphas)\n",
    "\n",
    "#生成一个RidgeCV实例\n",
    "ridge = RidgeCV(alphas=alphas, store_cv_values=True)  \n",
    "\n",
    "#模型训练\n",
    "ridge.fit(X_train, y_train)    \n",
    "\n",
    "#预测\n",
    "y_test_pred_ridge = ridge.predict(X_test)\n",
    "y_train_pred_ridge = ridge.predict(X_train)\n",
    "\n",
    "\n",
    "# 评估，使用r2_score评价模型在测试集和训练集上的性能\n",
    "print (\"The r2 score of RidgeCV on test is %f\" % r2_score(y_test, y_test_pred_ridge))\n",
    "print (\"The r2 score of RidgeCV on train is %f\" % r2_score(y_train, y_train_pred_ridge))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAZ4AAAEKCAYAAAAiizNaAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMi4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvhp/UCwAAIABJREFUeJzt3Xl8VOXd///XJzurgARklVX2PVBwAUVRtFZEZVFsta649Lb1W+9b7/663GrvWu9arXVDrbdtBQWtVuxdFFDQWgEJyBbCEhYxAiEIshNI+Pz+mAMdYyCDyczJ8n4+HvPIzDnXNedzhuWdc8411zF3R0REJFGSwi5ARERqFwWPiIgklIJHREQSSsEjIiIJpeAREZGEUvCIiEhCKXhERCShFDwiIpJQCh4REUmolLALqIqaNm3q7dq1C7sMEZFqZdGiRdvdPbO8dgqeMrRr147s7OywyxARqVbM7NNY2ulUm4iIJJSCR0REEkrBIyIiCaXgERGRhFLwiIhIQil4REQkoRQ8IiKSUPoeTyU6eLiEJ97Lo05aMnVSk6mTlkzdtGQyUiM/jy47ti41hYy0JNKSkzCzsMsXEUkIBU8l2n3wME/NzeOIn1y/5CT7aihFPa+blkxGWjJ1jy6LavOvUEuhTloSdVJTvtov6mdykoJNRKoGBU8latYgg3X/fQmHSo5w8NAR9h8u5sChEg4cLjn2c/+hEg4GP4+/rpgDh49w4FAxBXsOR5YfKmF/0Lao+MhJ15aekhQcZUWCrHQ4RcIuJfiZRN20lDKP1I72OXo0d3SdjtpEJFYKnkpmZqSnJJOekswppMZlG0eOeCSwSoVW5HkxB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XYEmBo8fwmInuzx6PNFRMIOIBV4wsz6AiXAGVHttxGZtkgkrhQ8IvFxvBuynehGbQeIzL+GmbUHfgwMdPedZvbi0XXliJ4Dqyj4WcK//q3/iMj8eH2InPE4GNU+I6hBJK50qk0kPj4AxplZcnDdZSiRiTw/JHKTtCQza07k1sdH5QKdgucNgX3ArqDdxcfZThKRmakBrgne/0ROAbYER1zfJXIr66POoGrMTC41nI54ROLjDSLXb5YSOQr5d3ffamZ/Ac4n8h/8GiJ3fdwV9Pk/IkE0292XmtknRGYuXg/88zjb2Qf0MLNFwfuMK6eup4C/mNkYIjNH74tad15Qg0hcaXZqkQQzs/oeuePkqUSOgs4KQqkOkTA4K7g2FMt77XX3+pVU1wfAKHffWRnvJ3I8OuIRSby/mVkjIA14wN23Arj7ATP7OZH72m9KZEHB6cDfKnQkEXTEIyIiCaXBBSIiklAKHhERSSgFj4iIJJSCR0REEkrBIyIiCaXgERGRhPr/Aa50bc+eTYujAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "alpha is: 100.0\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>columns</th>\n",
       "      <th>coef_lr</th>\n",
       "      <th>coef_ridge</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>2ndFlrSF</td>\n",
       "      <td>[0.2798480119217816]</td>\n",
       "      <td>[0.10329045009678285]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>OverallQual</td>\n",
       "      <td>[0.26640865950351794]</td>\n",
       "      <td>[0.2385622883746671]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>1stFlrSF</td>\n",
       "      <td>[0.2656173997572214]</td>\n",
       "      <td>[0.11966754522060069]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>BsmtFinSF1</td>\n",
       "      <td>[0.10989253674651933]</td>\n",
       "      <td>[0.10405076842035424]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>19</th>\n",
       "      <td>TotRmsAbvGrd</td>\n",
       "      <td>[0.10596469504353777]</td>\n",
       "      <td>[0.09473866650076485]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>TotalBsmtSF</td>\n",
       "      <td>[0.10109684424132556]</td>\n",
       "      <td>[0.10365166185672213]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>YearBuilt</td>\n",
       "      <td>[0.08344586707585637]</td>\n",
       "      <td>[0.07135960820605176]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>YearRemodAdd</td>\n",
       "      <td>[0.07210770120005856]</td>\n",
       "      <td>[0.07713209153322698]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>22</th>\n",
       "      <td>GarageCars</td>\n",
       "      <td>[0.07167564232808438]</td>\n",
       "      <td>[0.06694986539485863]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>LotArea</td>\n",
       "      <td>[0.06549398788305008]</td>\n",
       "      <td>[0.06086669383030795]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>23</th>\n",
       "      <td>GarageArea</td>\n",
       "      <td>[0.056587176144907346]</td>\n",
       "      <td>[0.062338356277988886]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>MasVnrArea</td>\n",
       "      <td>[0.05018458602582234]</td>\n",
       "      <td>[0.058015696627846225]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>LotFrontage</td>\n",
       "      <td>[0.039225534711106416]</td>\n",
       "      <td>[0.03995122995827868]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20</th>\n",
       "      <td>Fireplaces</td>\n",
       "      <td>[0.03384965167255298]</td>\n",
       "      <td>[0.04558615659008748]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>24</th>\n",
       "      <td>WoodDeckSF</td>\n",
       "      <td>[0.03317058510140644]</td>\n",
       "      <td>[0.036708082803312864]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>Id</td>\n",
       "      <td>[0.007196596768281257]</td>\n",
       "      <td>[0.0067749864871391174]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25</th>\n",
       "      <td>OpenPorchSF</td>\n",
       "      <td>[0.00450082969436748]</td>\n",
       "      <td>[0.009789851998811064]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>GrLivArea</td>\n",
       "      <td>[0.0019755310982400302]</td>\n",
       "      <td>[0.1615157749911224]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>BsmtFinSF2</td>\n",
       "      <td>[-0.0011780504047946361]</td>\n",
       "      <td>[-0.0029911854694670836]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16</th>\n",
       "      <td>HalfBath</td>\n",
       "      <td>[-0.003262494200630012]</td>\n",
       "      <td>[0.016638058189140683]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>BsmtFullBath</td>\n",
       "      <td>[-0.004066592459833486]</td>\n",
       "      <td>[0.00902877485030723]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>BsmtUnfSF</td>\n",
       "      <td>[-0.010493950450894874]</td>\n",
       "      <td>[-0.0016412899886381407]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>FullBath</td>\n",
       "      <td>[-0.01601733078785253]</td>\n",
       "      <td>[0.01443830427952189]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>21</th>\n",
       "      <td>GarageYrBlt</td>\n",
       "      <td>[-0.06683325230380059]</td>\n",
       "      <td>[-0.050991996173882746]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18</th>\n",
       "      <td>KitchenAbvGr</td>\n",
       "      <td>[-0.07995924897132729]</td>\n",
       "      <td>[-0.0739995519543332]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17</th>\n",
       "      <td>BedroomAbvGr</td>\n",
       "      <td>[-0.09459883857147754]</td>\n",
       "      <td>[-0.07389099446676818]</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "         columns                   coef_lr                coef_ridge\n",
       "12      2ndFlrSF      [0.2798480119217816]     [0.10329045009678285]\n",
       "3    OverallQual     [0.26640865950351794]      [0.2385622883746671]\n",
       "11      1stFlrSF      [0.2656173997572214]     [0.11966754522060069]\n",
       "7     BsmtFinSF1     [0.10989253674651933]     [0.10405076842035424]\n",
       "19  TotRmsAbvGrd     [0.10596469504353777]     [0.09473866650076485]\n",
       "10   TotalBsmtSF     [0.10109684424132556]     [0.10365166185672213]\n",
       "4      YearBuilt     [0.08344586707585637]     [0.07135960820605176]\n",
       "5   YearRemodAdd     [0.07210770120005856]     [0.07713209153322698]\n",
       "22    GarageCars     [0.07167564232808438]     [0.06694986539485863]\n",
       "2        LotArea     [0.06549398788305008]     [0.06086669383030795]\n",
       "23    GarageArea    [0.056587176144907346]    [0.062338356277988886]\n",
       "6     MasVnrArea     [0.05018458602582234]    [0.058015696627846225]\n",
       "1    LotFrontage    [0.039225534711106416]     [0.03995122995827868]\n",
       "20    Fireplaces     [0.03384965167255298]     [0.04558615659008748]\n",
       "24    WoodDeckSF     [0.03317058510140644]    [0.036708082803312864]\n",
       "0             Id    [0.007196596768281257]   [0.0067749864871391174]\n",
       "25   OpenPorchSF     [0.00450082969436748]    [0.009789851998811064]\n",
       "13     GrLivArea   [0.0019755310982400302]      [0.1615157749911224]\n",
       "8     BsmtFinSF2  [-0.0011780504047946361]  [-0.0029911854694670836]\n",
       "16      HalfBath   [-0.003262494200630012]    [0.016638058189140683]\n",
       "14  BsmtFullBath   [-0.004066592459833486]     [0.00902877485030723]\n",
       "9      BsmtUnfSF   [-0.010493950450894874]  [-0.0016412899886381407]\n",
       "15      FullBath    [-0.01601733078785253]     [0.01443830427952189]\n",
       "21   GarageYrBlt    [-0.06683325230380059]   [-0.050991996173882746]\n",
       "18  KitchenAbvGr    [-0.07995924897132729]     [-0.0739995519543332]\n",
       "17  BedroomAbvGr    [-0.09459883857147754]    [-0.07389099446676818]"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "mse_mean = np.mean(ridge.cv_values_, axis = 0)\n",
    "plt.plot(np.log10(alphas), mse_mean.reshape(len(alphas),1)) \n",
    "\n",
    "#这是为了标出最佳参数的位置，不是必须\n",
    "#plt.plot(np.log10(ridge.alpha_)*np.ones(3), [0.28, 0.29, 0.30])\n",
    "\n",
    "plt.xlabel('log(alpha)')\n",
    "plt.ylabel('mse')\n",
    "plt.show()\n",
    "\n",
    "print ('alpha is:', ridge.alpha_)\n",
    "\n",
    "# 看看各特征的权重系数，系数的绝对值大小可视为该特征的重要性\n",
    "fs = pd.DataFrame({\"columns\":list(columns), \"coef_lr\":list((lr.coef_.T)), \"coef_ridge\":list((ridge.coef_.T))})\n",
    "fs.sort_values(by=['coef_lr'],ascending=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The r2 score of LassoCV on test is 0.6553152255218736\n",
      "The r2 score of LassoCV on train is 0.8309665784960352\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "C:\\Users\\YuGo\\Anaconda3\\lib\\site-packages\\sklearn\\linear_model\\coordinate_descent.py:1094: DataConversionWarning: A column-vector y was passed when a 1d array was expected. Please change the shape of y to (n_samples, ), for example using ravel().\n",
      "  y = column_or_1d(y, warn=True)\n"
     ]
    }
   ],
   "source": [
    "#### Lasso／L1正则\n",
    "# class sklearn.linear_model.LassoCV(eps=0.001, n_alphas=100, alphas=None, fit_intercept=True, \n",
    "#                                    normalize=False, precompute=’auto’, max_iter=1000, \n",
    "#                                    tol=0.0001, copy_X=True, cv=None, verbose=False, n_jobs=1,\n",
    "#                                    positive=False, random_state=None, selection=’cyclic’)\n",
    "from sklearn.linear_model import LassoCV\n",
    "\n",
    "#设置超参数搜索范围\n",
    "#alphas = [ 0.01, 0.1, 1, 10,100]\n",
    "\n",
    "#生成一个LassoCV实例\n",
    "#lasso = LassoCV(alphas=alphas)  \n",
    "lasso = LassoCV()  \n",
    "\n",
    "#训练（内含CV）\n",
    "lasso.fit(X_train, y_train)  \n",
    "\n",
    "#测试\n",
    "y_test_pred_lasso = lasso.predict(X_test)\n",
    "y_train_pred_lasso = lasso.predict(X_train)\n",
    "\n",
    "\n",
    "# 评估，使用r2_score评价模型在测试集和训练集上的性能\n",
    "print ('The r2 score of LassoCV on test is', r2_score(y_test, y_test_pred_lasso))\n",
    "print ('The r2 score of LassoCV on train is', r2_score(y_train, y_train_pred_lasso))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYUAAAEKCAYAAAD9xUlFAAAABHNCSVQICAgIfAhkiAAA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tl9ffOGkXpNme7g3zi//jv8E5LXErqQ5Fp8V0r7iqAGkVBp85GMRr8AbjSz4mA7/2+QvFjYc8AHgn0LU3nzZdK3AucEw+OB40Bb0O7aQV6niOSVKQE+Eix/KBOAfcGayu+SvN1inwXk7xVTJY9oTUFGo4dJ7i94leSv9z939/1m9t/Ae0h++W4HfkXyTlWQvL/GlcCT7v6qmW0geSXTXcDzg7zOcWCxmb0cLOfGYer6BvDfZvYh4Ong+X3eHdQgEipdJVUkhZlVunuHmU0hufZwWRAYY0h+UV8W7IvIZFkd7l45QnX9AljhyXuDi4RGawoib/aImU0EyoAvu/t+AHfvNLPbSd7ztjGbBQWbuP5ZgSDZoDUFERHppx3NIiLST6EgIiL9FAoiItJPoSAiIv0UCiIi0k+hICIi/f4/c3MpTuFG/SgAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "alpha is: 0.0008456506189417725\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>columns</th>\n",
       "      <th>coef_lr</th>\n",
       "      <th>coef_ridge</th>\n",
       "      <th>coef_lasso</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>2ndFlrSF</td>\n",
       "      <td>[0.2798480119217816]</td>\n",
       "      <td>[0.10329045009678285]</td>\n",
       "      <td>0.227342</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>OverallQual</td>\n",
       "      <td>[0.26640865950351794]</td>\n",
       "      <td>[0.2385622883746671]</td>\n",
       "      <td>0.267203</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>1stFlrSF</td>\n",
       "      <td>[0.2656173997572214]</td>\n",
       "      <td>[0.11966754522060069]</td>\n",
       "      <td>0.223024</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>BsmtFinSF1</td>\n",
       "      <td>[0.10989253674651933]</td>\n",
       "      <td>[0.10405076842035424]</td>\n",
       "      <td>0.117303</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>19</th>\n",
       "      <td>TotRmsAbvGrd</td>\n",
       "      <td>[0.10596469504353777]</td>\n",
       "      <td>[0.09473866650076485]</td>\n",
       "      <td>0.102421</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>TotalBsmtSF</td>\n",
       "      <td>[0.10109684424132556]</td>\n",
       "      <td>[0.10365166185672213]</td>\n",
       "      <td>0.091541</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>YearBuilt</td>\n",
       "      <td>[0.08344586707585637]</td>\n",
       "      <td>[0.07135960820605176]</td>\n",
       "      <td>0.080921</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>YearRemodAdd</td>\n",
       "      <td>[0.07210770120005856]</td>\n",
       "      <td>[0.07713209153322698]</td>\n",
       "      <td>0.071492</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>22</th>\n",
       "      <td>GarageCars</td>\n",
       "      <td>[0.07167564232808438]</td>\n",
       "      <td>[0.06694986539485863]</td>\n",
       "      <td>0.069711</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>LotArea</td>\n",
       "      <td>[0.06549398788305008]</td>\n",
       "      <td>[0.06086669383030795]</td>\n",
       "      <td>0.064881</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>23</th>\n",
       "      <td>GarageArea</td>\n",
       "      <td>[0.056587176144907346]</td>\n",
       "      <td>[0.062338356277988886]</td>\n",
       "      <td>0.056190</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>MasVnrArea</td>\n",
       "      <td>[0.05018458602582234]</td>\n",
       "      <td>[0.058015696627846225]</td>\n",
       "      <td>0.050747</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>LotFrontage</td>\n",
       "      <td>[0.039225534711106416]</td>\n",
       "      <td>[0.03995122995827868]</td>\n",
       "      <td>0.038575</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20</th>\n",
       "      <td>Fireplaces</td>\n",
       "      <td>[0.03384965167255298]</td>\n",
       "      <td>[0.04558615659008748]</td>\n",
       "      <td>0.034078</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>24</th>\n",
       "      <td>WoodDeckSF</td>\n",
       "      <td>[0.03317058510140644]</td>\n",
       "      <td>[0.036708082803312864]</td>\n",
       "      <td>0.032968</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>Id</td>\n",
       "      <td>[0.007196596768281257]</td>\n",
       "      <td>[0.0067749864871391174]</td>\n",
       "      <td>0.006463</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25</th>\n",
       "      <td>OpenPorchSF</td>\n",
       "      <td>[0.00450082969436748]</td>\n",
       "      <td>[0.009789851998811064]</td>\n",
       "      <td>0.003824</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>GrLivArea</td>\n",
       "      <td>[0.0019755310982400302]</td>\n",
       "      <td>[0.1615157749911224]</td>\n",
       "      <td>0.057939</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>BsmtFinSF2</td>\n",
       "      <td>[-0.0011780504047946361]</td>\n",
       "      <td>[-0.0029911854694670836]</td>\n",
       "      <td>0.000613</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16</th>\n",
       "      <td>HalfBath</td>\n",
       "      <td>[-0.003262494200630012]</td>\n",
       "      <td>[0.016638058189140683]</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>BsmtFullBath</td>\n",
       "      <td>[-0.004066592459833486]</td>\n",
       "      <td>[0.00902877485030723]</td>\n",
       "      <td>-0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>BsmtUnfSF</td>\n",
       "      <td>[-0.010493950450894874]</td>\n",
       "      <td>[-0.0016412899886381407]</td>\n",
       "      <td>-0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>FullBath</td>\n",
       "      <td>[-0.01601733078785253]</td>\n",
       "      <td>[0.01443830427952189]</td>\n",
       "      <td>-0.010078</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>21</th>\n",
       "      <td>GarageYrBlt</td>\n",
       "      <td>[-0.06683325230380059]</td>\n",
       "      <td>[-0.050991996173882746]</td>\n",
       "      <td>-0.063020</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18</th>\n",
       "      <td>KitchenAbvGr</td>\n",
       "      <td>[-0.07995924897132729]</td>\n",
       "      <td>[-0.0739995519543332]</td>\n",
       "      <td>-0.078852</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17</th>\n",
       "      <td>BedroomAbvGr</td>\n",
       "      <td>[-0.09459883857147754]</td>\n",
       "      <td>[-0.07389099446676818]</td>\n",
       "      <td>-0.092014</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "         columns                   coef_lr                coef_ridge  \\\n",
       "12      2ndFlrSF      [0.2798480119217816]     [0.10329045009678285]   \n",
       "3    OverallQual     [0.26640865950351794]      [0.2385622883746671]   \n",
       "11      1stFlrSF      [0.2656173997572214]     [0.11966754522060069]   \n",
       "7     BsmtFinSF1     [0.10989253674651933]     [0.10405076842035424]   \n",
       "19  TotRmsAbvGrd     [0.10596469504353777]     [0.09473866650076485]   \n",
       "10   TotalBsmtSF     [0.10109684424132556]     [0.10365166185672213]   \n",
       "4      YearBuilt     [0.08344586707585637]     [0.07135960820605176]   \n",
       "5   YearRemodAdd     [0.07210770120005856]     [0.07713209153322698]   \n",
       "22    GarageCars     [0.07167564232808438]     [0.06694986539485863]   \n",
       "2        LotArea     [0.06549398788305008]     [0.06086669383030795]   \n",
       "23    GarageArea    [0.056587176144907346]    [0.062338356277988886]   \n",
       "6     MasVnrArea     [0.05018458602582234]    [0.058015696627846225]   \n",
       "1    LotFrontage    [0.039225534711106416]     [0.03995122995827868]   \n",
       "20    Fireplaces     [0.03384965167255298]     [0.04558615659008748]   \n",
       "24    WoodDeckSF     [0.03317058510140644]    [0.036708082803312864]   \n",
       "0             Id    [0.007196596768281257]   [0.0067749864871391174]   \n",
       "25   OpenPorchSF     [0.00450082969436748]    [0.009789851998811064]   \n",
       "13     GrLivArea   [0.0019755310982400302]      [0.1615157749911224]   \n",
       "8     BsmtFinSF2  [-0.0011780504047946361]  [-0.0029911854694670836]   \n",
       "16      HalfBath   [-0.003262494200630012]    [0.016638058189140683]   \n",
       "14  BsmtFullBath   [-0.004066592459833486]     [0.00902877485030723]   \n",
       "9      BsmtUnfSF   [-0.010493950450894874]  [-0.0016412899886381407]   \n",
       "15      FullBath    [-0.01601733078785253]     [0.01443830427952189]   \n",
       "21   GarageYrBlt    [-0.06683325230380059]   [-0.050991996173882746]   \n",
       "18  KitchenAbvGr    [-0.07995924897132729]     [-0.0739995519543332]   \n",
       "17  BedroomAbvGr    [-0.09459883857147754]    [-0.07389099446676818]   \n",
       "\n",
       "    coef_lasso  \n",
       "12    0.227342  \n",
       "3     0.267203  \n",
       "11    0.223024  \n",
       "7     0.117303  \n",
       "19    0.102421  \n",
       "10    0.091541  \n",
       "4     0.080921  \n",
       "5     0.071492  \n",
       "22    0.069711  \n",
       "2     0.064881  \n",
       "23    0.056190  \n",
       "6     0.050747  \n",
       "1     0.038575  \n",
       "20    0.034078  \n",
       "24    0.032968  \n",
       "0     0.006463  \n",
       "25    0.003824  \n",
       "13    0.057939  \n",
       "8     0.000613  \n",
       "16    0.000000  \n",
       "14   -0.000000  \n",
       "9    -0.000000  \n",
       "15   -0.010078  \n",
       "21   -0.063020  \n",
       "18   -0.078852  \n",
       "17   -0.092014  "
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "mses = np.mean(lasso.mse_path_, axis = 1)\n",
    "plt.plot(np.log10(lasso.alphas_), mses) \n",
    "#plt.plot(np.log10(lasso.alphas_)*np.ones(3), [0.3, 0.4, 1.0])\n",
    "plt.xlabel('log(alpha)')\n",
    "plt.ylabel('mse')\n",
    "plt.show()    \n",
    "            \n",
    "print ('alpha is:', lasso.alpha_)\n",
    "\n",
    "# 看看各特征的权重系数，系数的绝对值大小可视为该特征的重要性\n",
    "fs = pd.DataFrame({\"columns\":list(columns), \"coef_lr\":list((lr.coef_.T)), \"coef_ridge\":list((ridge.coef_.T)), \"coef_lasso\":list((lasso.coef_.T))})\n",
    "fs.sort_values(by=['coef_lr'],ascending=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYUAAAEKCAYAAAD9xUlFAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMi4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvhp/UCwAAIABJREFUeJzt3XuYlPV99/H3d8/AL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UFGo4dJ7i94leSv9z939/1m9t/Ae0h++W4HfkXyTlWQvL/GlcCT7v6qmW0geSXTXcDzg7zOcWCxmb0cLOfGYer6BvDfZvYh4Ong+X3eHdQgEipdJVUkhZlVunuHmU0hufZwWRAYY0h+UV8W7IvIZFkd7l45QnX9AljhyXuDi4RGawoib/aImU0EyoAvu/t+AHfvNLPbSd7ztjGbBQWbuP5ZgSDZoDUFERHppx3NIiLST6EgIiL9FAoiItJPoSAiIv0UCiIi0k+hICIi/f4/c3MpTuFG/SgAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "alpha is: 0.0008456506189417725\n"
     ]
    }
   ],
   "source": [
    "mses = np.mean(lasso.mse_path_, axis = 1)\n",
    "plt.plot(np.log10(lasso.alphas_), mses) \n",
    "#plt.plot(np.log10(lasso.alphas_)*np.ones(3), [0.3, 0.4, 1.0])\n",
    "plt.xlabel('log(alpha)')\n",
    "plt.ylabel('mse')\n",
    "plt.show()    \n",
    "            \n",
    "print ('alpha is:', lasso.alpha_)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
